package farmaciaweb.com.br.entity;


import java.io.Serializable;
import java.lang.String;
import java.util.Collection;

import javax.persistence.*;

import static javax.persistence.GenerationType.SEQUENCE;

/**
 * Entity implementation class for Entity: Indicacao
 *
 */
@Entity
@NamedQueries(value = {
		@NamedQuery(name = "bd_farmaciaweb.consultaIndicacao", query = "SELECT i FROM Indicacao i " +
																"where (i.descricao like :desc) " )})

public class Indicacao implements Serializable{

	   
	/**
	 * 
	 */
	private static final long serialVersionUID = 7838838896358817297L;

	@Id
	@Column (name = "idIndicacao")
	@GeneratedValue(strategy = SEQUENCE, generator = "indic_gen")
	@SequenceGenerator(name = "indic_gen", sequenceName = "indic_seq", allocationSize = 5)
	private int idIndicacao;
	
	@Column(nullable = false, length = 50)
	private String descricao;
	
	@OneToMany(mappedBy = "indicacao")
	private Collection<Medicamento> medicamento;

	public Indicacao() {
		super();
	}   
	public int getIdIndicacao() {
		return this.idIndicacao;
	}

	public void setIdIndicacao(int idIndicacao) {
		this.idIndicacao = idIndicacao;
	}   
	public String getDescricao() {
		return this.descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + idIndicacao;
		result = prime * result
				+ ((medicamento == null) ? 0 : medicamento.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Indicacao other = (Indicacao) obj;
		if (idIndicacao != other.idIndicacao)
			return false;
		if (medicamento == null) {
			if (other.medicamento != null)
				return false;
		} else if (!medicamento.equals(other.medicamento))
			return false;
		return true;
	}
	
	
	
}
